package org.zfes.snowier.cloud.zbss.loan.loan.controller;

import java.util.Map;
import java.util.Optional;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.cloud.zbss.loan.loan.model.LoanCategory;
import org.zfes.snowier.cloud.zbss.loan.loan.service.ILoanCategoryService;
@Controller 
@RequestMapping("/loan/loanCategory")
public class LoanCategoryController extends BaseController {

	
	@Autowired
	private ILoanCategoryService loanCategoryService;
	
	//@RequiresPermissions(value="loanCategory:loadLoanCategoryDataSet",desc="贷款类别列表")
    @RequestMapping(value="/loadLoanCategoryDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadLoanCategoryDataSet(@RequestParam Map<String,Object> params){
	    DataSet dataSet=  loanCategoryService.loadLoanCategoryDataSet(params);
	    return ajaxQuery("dataSet", dataSet);
    }
	
	//@RequiresPermissions(value="loanCategory:createLoanCategory",desc="贷款类别添加")
    @RequestMapping(value="/createLoanCategory", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public  @ResponseBody Object createLoanCategory(LoanCategory loanCategory){
		loanCategoryService.createLoanCategory(loanCategory);
    	return ajaxDoneSuccess("数据操作成功 ");
    }
	
	//@RequiresPermissions(value="loanCategory:loadLoanCategory",desc="贷款类别加载")
    @RequestMapping(value="/loadLoanCategory", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadLoanCategory(Long id){
		Optional<LoanCategory> ops = loanCategoryService.loadLoanCategoryById(id);
		return ajaxQuery("loanCategory",ops);
    }
	
	//@RequiresPermissions(value="loanCategory:updateLoanCategory",desc="贷款类别更新")
    @RequestMapping(value="/updateLoanCategory", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object updateLoanCategory(LoanCategory loanCategory){
		loanCategoryService.updateLoanCategory(loanCategory);
		return ajaxDoneSuccess("数据操作成功 ");
    }
	
	//@RequiresPermissions(value="loanCategory:deletLoanCategory",desc="贷款类别删除")
    @RequestMapping(value="/deleteLoanCategory", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object deleteLoanCategory(Long id){
		loanCategoryService.deleteLoanCategory(id);
		return ajaxDoneSuccess("数据操作成功 ");
    }

}